package com.systemsjr.jrenterprise.utils;

import java.util.Date;

import com.systemsjr.jrenterprise.ServiceLocator;
import com.systemsjr.jrenterprise.appointment.service.AppointmentService;
import com.systemsjr.jrenterprise.appointment.vo.AppointmentVO;
import com.systemsjr.jrenterprise.customer.service.CustomerService;
import com.systemsjr.jrenterprise.customer.vo.CustomerVO;
import com.systemsjr.jrenterprise.invoice.service.InvoiceService;
import com.systemsjr.jrenterprise.invoice.vo.InvoiceVO;
import com.systemsjr.jrenterprise.service.service.ServiceService;
import com.systemsjr.jrenterprise.service.vo.ServiceVO;
import com.systemsjr.jrenterprise.setting.service.SystemSettingService;
import com.systemsjr.jrenterprise.setting.vo.SystemSettingVO;
import com.systemsjr.jrenterprise.user.service.UserService;
import com.systemsjr.jrenterprise.user.vo.UserDetailsVO;

public class ServiceUtils{
	
	private static ServiceLocator serviceLocator = ServiceLocator.instance();
	private static UserService userService;
	private static AppointmentService appointmentService;
	private static CustomerService customerService;
	private static InvoiceService invoiceService;
	private static ServiceService serviceService;
	private static SystemSettingService settingService;
	
	public static UserService getUserService(){
		
		if(userService == null){
			userService = serviceLocator.getUserService();
		}
		
		return userService;
	}
	
	public static AppointmentService getAppointmentService() {
		if(appointmentService == null){
			appointmentService = serviceLocator.getAppointmentService();
		}
		return appointmentService;
	}

	public static CustomerService getCustomerService() {
		
		if(customerService == null){
			customerService = serviceLocator.getCustomerService();
		}
		
		return customerService;
	}

	public static InvoiceService getInvoiceService() {
		
		if(invoiceService == null){
			invoiceService = serviceLocator.getInvoiceService();
		}
		
		return invoiceService;
	}

	public static ServiceService getServiceService() {
		
		if(serviceService == null){
			serviceService = serviceLocator.getServiceService();
		}
		
		return serviceService;
	}
	
	public static SystemSettingService getSettingService() {
		
		if(settingService == null){
			settingService = serviceLocator.getSystemSettingService();
		}
		
		return settingService;
	}
	
	public static CustomerVO createDefaultCustomer(){
		return new CustomerVO();
	}
	
	public static InvoiceVO createDefaultInvoice(){
		
		InvoiceVO invoice = new InvoiceVO();
		invoice.setInvoiceDate(new Date());
		return invoice;
	}
	
	public static ServiceVO createDefaultService(){
		return new ServiceVO();
	}

	public static UserDetailsVO createDefaultUser() {
		
		return new UserDetailsVO();
	}
	
	public static AppointmentVO createDefaultAppointment(){
		AppointmentVO appointment = new AppointmentVO();
		
		appointment.setAppDate(new Date());
		
		return appointment;
	}
	
	public static SystemSettingVO createDefaultSetting(){
		return new SystemSettingVO();
	}

}
